var basic_login_state;
$(function(){
	$(".show-fldy").hover(function(){
		$(".hide-fldy-div").show();
	},function(){
		$(".hide-fldy-div").hide();
	})
	$(".hide-fldy-div").hover(function(){
		$(".hide-fldy-div").show();
	},function(){
		$(".hide-fldy-div").hide();
	})
	
	var recruiter_id = $("#recruiter_id").val();
	if(recruiter_id!=""){
		utilAjax("/recruiter/queryNewsMessageByRecruiter_id","recruiter_id="+recruiter_id,"post",
				function(data){
			$("#re_image").attr("src","/image/"+data.company_msg.company_img);
			$("#rec_name").text(data.recruiter_name);
			$("#rec_company").text(data.company_msg.company_name);
			$("#rec_phone").text(data.recruiter_phone);
			$("#com_jod").text(data.company_msg.company_introduce);
			$("#com_address").text(data.company_msg.company_address);
			$("#com_phone").text(data.company_msg.company_phone);
		});
	}
	
	basic_login_state = $("#basic_login_state").val();
	
	$('textarea[autoHeight]').autoHeight();
})

function touDiJianLi(recruiter_id,rec_title){
	if(basic_login_state==1){
		var res_id = $("#res_id").val();
		if(res_id!=""){
			// recruiter_id
			// rec_title
			// res_id
			$("#myModal3").modal('show');
			utilAjax("/doc_resumes/queryAllByBasic_id","","post",function(data){
				var dataSize = data.list.length;
				var docCon = "";
				if(dataSize!=0){
					docCon +="<tr>" +
								"<th height='40'>文档标题</th>" +
								"<th>文档地址</th>"+
								"<th>操作</th>"+
							"</tr>";
					$.each(data.list,function(i,d){
						docCon +="<tr>" +
								"<th height='40'>"+d.doc_title+"</th>" +
								"<th>"+d.doc_url+"</th>"+
								"<th>" +
									"<input type='button' onclick=insertDeliver_resumeOne("+d.doc_id+","+recruiter_id+",'"+rec_title+"') value='投递' class='btn btn-default'>" +
								"</th>"+
							"</tr>";
					});
				}else{
					docCon += "<tr><td align='center'><font size='3' color='red'>没有简历？<a href='/view/resume.jsp'>立即上传</a></font></td></tr>";
				}
				$("#allDoc_resumesTable").html(docCon);
			});
		}else{
			alert("请填写在线简历后在投递！！！");
		}
	}else{
		alert("请登录后，在尝试投递！！！");
	}
}
function insertDeliver_resumeOne(doc_id,recruiter_id,rec_title){
	utilAjax("/deliver_resume/insertDeliver_resumeOne","doc_id="+doc_id+"&recruiter_id="+recruiter_id+"&rec_title="+rec_title,"post",
			function(flag){
		if(flag){
			$("#myModal3").modal('hide');
		}else{
			alert("投递失败");
		}
	});
}

function juBaoZhaoPinMessage(rec_id){
	// 举报招聘信息
	if(basic_login_state==1){
		$("#myModal").modal('show');
		$("#rec_idgogo").val(rec_id);
	}else{
		alert("请登录后，在尝试举报该招聘信息");
	}
}

function juBaoZhaoPinZheMessage(recruiter_id){
	// 举报招聘者
	if(basic_login_state==1){
		$("#myModal2").modal('show');
		$("#recruiter_idgogo").val(recruiter_id);
	}else{
		alert("请登录后，在尝试举报该招聘信息");
	}
}

function utilAjax(url,data,type,success){
	$.ajax({
		url:url,
		data:data,
		dataType:'json',
		type:type,
		success:success,
		error:function(){
		}
	});
}


function goJuBaoMessage(){
	// 立即举报招聘信息
	var conMessage = $("#juBaoMessageForm").serialize();
	var rri_context = $("[name='rri_context']").val();
	if(rri_context==""){
		alert("举报内容不能为空哦");
	}else{
		utilAjax("/report_recruitment_msg/insertReport_recruitment_msg",conMessage,"post",
				function(flag){
			if(!flag){
				alert("举报失败，请稍后再试！！！");
			}
			$("#myModal").modal('hide');
		});
	}
}

function goJuBaoZhe(){
	// 立即举报招聘者
	var conMessage = $("#juBaoZhaoPinZheForm").serialize();
	var rrp_context = $("[name='rrp_context']").val();
	if(rrp_context==""){
		alert("举报内容不能为空哦");
	}else{
		utilAjax("/report_recruitment_person/insertReport_recruitment_person",conMessage,"post",
				function(flag){
			if(!flag){
				alert("举报失败，请稍后再试！！！");
			}
			$("#myModal2").modal('hide');
		});
	}
	
}

$.fn.autoHeight = function(){
	function autoHeight(elem){
		elem.style.height = 'auto';
		elem.scrollTop = 0; // 防抖动
		elem.style.height = elem.scrollHeight + 'px';
	}
	this.each(function(){
		autoHeight(this);
		$(this).on('keyup', function(){
			autoHeight(this);
		});
	});
}
	
